<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>编辑申购</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <el-form :model="infoForm" label-width="120px" ref="editForm">
          <el-form-item label="期望交付日期：" v-if="itemlable=='expect_time'">
            <el-date-picker type="date"
                            size="small"
                            placeholder="选择日期"
                            v-model="infoForm.expect_time"
                            :picker-options="pickerOptions1"
                            value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
          <el-form-item label="采购网址：" prop="num" v-if="itemlable=='url'">
            <el-input v-model="infoForm.url" placeholder="采购网址" size="small"></el-input>
          </el-form-item>
          <el-form-item label="单价：" prop="num" v-if="itemlable=='price'">
            <el-input v-model="infoForm.price" placeholder="单价" size="small"></el-input>
          </el-form-item>
          <el-form-item label="单位：" prop="num" v-if="itemlable=='unit'">
            <el-input v-model="infoForm.unit" placeholder="单位" size="small"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="closePOpup" size="small">取消</el-button>
        <el-button size="small" type="primary" @click="checkEditFn">确定修改</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['visible', 'itemlable','itemValue'], // recruitmentType examine 审核
  components: {},
  data() {
    return {
      dialogVisible: false,
      infoForm: {
        name: '',
        cate_id: '',
        reason: '',
        unit: '', // "单位",
        need_number: 1,
        price: '',
        pic: '',
        url: '',
        expect_time: '',
        remark: '',
        cate_son_id: ''
      },
      pickerOptions1: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7
        }
      },
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if(this.visible){
        console.log('this.itemlable', this.itemlable, this.itemValue)
        this.infoForm[this.itemlable] = this.itemValue
      }
    }
  },
  created() {

  },
  methods: {
    checkEditFn(){
      if(!this.infoForm[this.itemlable]){
        this.$message.error('请填写信息');
        return
      }
      this.$emit('checkList',{name: this.itemlable,val: this.infoForm[this.itemlable]})
      this.closePOpup()
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 500px;
  height: 300px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 70px 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.resruitment-title {
  padding: 5px 0;
  border-bottom: 2px solid #abd3f3;
  margin-bottom: 20px;
}

.el-radio {
  margin-right: 20px;
}

.jobTime {
  display: flex;
  align-items: center;
}

.jobTime span {
  padding: 0 10px;
}
</style>


